<?php
declare (strict_types = 1);

namespace app\middleware;

use app\model\User;
use think\facade\Cookie;

class CheckRememberMe
{
  public function handle($request, \Closure $next)
    {
        if(!session('?user')){
            if($user_id = Cookie::get('user_id')){
               $session_user = User::find($user_id);
               session('user',$session_user);
            }
        }
        return $next($request);
    }
}
